{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "b28b2b2c",
   "metadata": {},
   "outputs": [
    {
     "ename": "IndentationError",
     "evalue": "expected an indented block (<ipython-input-17-959d7a448935>, line 18)",
     "output_type": "error",
     "traceback": [
      "\u001b[1;36m  File \u001b[1;32m\"<ipython-input-17-959d7a448935>\"\u001b[1;36m, line \u001b[1;32m18\u001b[0m\n\u001b[1;33m    print(\"商品编号：%s，商品的名称：%s，商品的价格：%s 元\"%s(i,goods_list[i][0],goos_list[0][i]))\u001b[0m\n\u001b[1;37m    ^\u001b[0m\n\u001b[1;31mIndentationError\u001b[0m\u001b[1;31m:\u001b[0m expected an indented block\n"
     ]
    }
   ],
   "source": [
    "#商品列表数据\n",
    "good_list = [\n",
    "    # 商品樣式：[商品名稱，商品價格],\n",
    "    ['珍珠奶茶',5],\n",
    "    ['大杯珍珠奶茶',8.5]\n",
    "]\n",
    "# 写到某一步进行优化\n",
    "user_shopping_cart = []\n",
    "# 用户输入：input \n",
    "Alipay = int(input(\"请输入您的余额：\"))\n",
    "\n",
    "# 打印商品信息，打印商品的次数是由商品的长度决定的(len(good_list))\n",
    "while True:   \n",
    "    print(\"----商品列表信息----\")\n",
    "    for i in range(len(goods_list)):\n",
    "    #给格式化的样式（先给）\n",
    "    #  :\"商品编号：xx，商品的名称：xx，商品的价格：xx\"\n",
    "    print(\"商品编号：%s，商品的名称：%s，商品的价格：%s 元\"%s(i,goods_list[i][0],goos_list[0][i]))\n",
    "    \n",
    "    # 用户输入商品编号\n",
    "    choice = input(\"请输入正确的商品编号进行购买(如果退出请输入“q”)：\") \n",
    "    if choice.isdigit(): \n",
    "    choice = int(choice) \n",
    "# 判断商品编号是否在我们的范围内\n",
    "    if choice > len(goods_list): \n",
    "    print(\"您输入的商品不存在，请检查再次输入\")\n",
    "    else: \n",
    "    # 对比商品编号，找到对应商品，商品价格：goods_list[choice][i]\n",
    "    if Alipay > goods_list[choice]][1]: \n",
    "    Alipay > goods_list[choice][1]\n",
    "    user_shopping_cart.append(goods_list[choice])\n",
    "    print(\"【%s】已经加入您的购物车，您的【余额】还有 %s 元\"%(goods_list[choice][0],Alipay))\n",
    "    else: \n",
    "        print(\"您的月不足以购买，请更换支付方式\") \n",
    "    elif choice == \"q\": "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "9ca6c261",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
